package com.repository;

import com.entity.BuildingRentalInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface BuildingRentalRepository extends JpaRepository<BuildingRentalInfo, Integer> {
    List<BuildingRentalInfo> findByBuildingCode(String buildingCode);
    
    @Query("SELECT b FROM BuildingRentalInfo b WHERE b.buildingCode = :buildingCode AND b.endDate > :currentDate")
    List<BuildingRentalInfo> findByBuildingCodeAndEndDateAfter(@Param("buildingCode") String buildingCode, @Param("currentDate") Date currentDate);

    void deleteByBuildingCode(String buildingCode);
}